package nccloud.web.ic.whstrans.action;

import nc.util.mmf.framework.base.MMValueCheck;
import nc.vo.ic.m4k.entity.WhsTransBillBodyVO;
import nc.vo.ic.m4k.entity.WhsTransBillVO;
import nc.vo.scmpub.util.TransferSortUtil;
import nccloud.framework.core.exception.ExceptionUtils;
import nccloud.framework.web.action.itf.ICommonAction;
import nccloud.framework.web.container.IRequest;
import nccloud.framework.web.ui.pattern.extbillcard.ExtBillCard;
import nccloud.framework.web.ui.pattern.extbillcard.ExtBillCardOperator;
import nccloud.web.codeplatform.framework.action.base.VOTransform;
import nccloud.web.scmpub.pub.action.TempletQueryAction;
import nccloud.web.codeplatform.framework.action.base.ResultWapper;


public class PurchseinToWhAction implements ICommonAction{

	@Override
	public Object doAction(IRequest request) {

		//ExtBillCard[] cards = null;
		try {
			Refm45TransferUtil transferUtils = new Refm45TransferUtil();
			WhsTransBillVO[] vos = transferUtils.getWhsTransBillVO(request);

		  //vos = (WhsTransBillVO[]) (new TransferSortUtil("vsourcerowno", "vsourcebillcode")).sort(vos);
			
			if(MMValueCheck.isNotEmpty(vos)) {
				for(WhsTransBillVO vo : vos) {
					WhsTransBillBodyVO[] whsTransBillBodyVOs = vo.getBodys();
					if(MMValueCheck.isNotEmpty(whsTransBillBodyVOs)) {
						for(int i = 0; i <whsTransBillBodyVOs.length ; i++ ) {
							whsTransBillBodyVOs[i].setCrowno(Integer.toString((i+1)*10));
						}
					}
				}
			}
			
			String templetid =  TempletQueryAction.getTempletIdByAppCode("400801606", "400801606_card");
	        String pagecode = "400801606_card";
          
	        
	        return new VOTransform(templetid,pagecode).toList(vos, "head", new String[]{ "whstrans_b"}, null);
		} catch (Exception e) {
			ExceptionUtils.wrapException(e);
			return null;
		}
		//return cards;
	}


	

}
